package com.example.dryyzx.dao;

import com.example.dryyzx.entity.NursingContent;
import org.apache.ibatis.jdbc.SQL;

public class NursingContentSqlProvider {
    public String insertSelective(NursingContent record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("nursing_content");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            sql.VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getPrice() != null) {
            sql.VALUES("price", "#{price,jdbcType=INTEGER}");
        }
        
        if (record.getRemarks() != null) {
            sql.VALUES("remarks", "#{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getValueAddedServices() != null) {
            sql.VALUES("value_added_services", "#{valueAddedServices,jdbcType=BIT}");
        }
        
        if (record.getEnable() != null) {
            sql.VALUES("enable", "#{enable,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(NursingContent record) {
        SQL sql = new SQL();
        sql.UPDATE("nursing_content");
        
        if (record.getName() != null) {
            sql.SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getPrice() != null) {
            sql.SET("price = #{price,jdbcType=INTEGER}");
        }
        
        if (record.getRemarks() != null) {
            sql.SET("remarks = #{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getValueAddedServices() != null) {
            sql.SET("value_added_services = #{valueAddedServices,jdbcType=BIT}");
        }
        
        if (record.getEnable() != null) {
            sql.SET("enable = #{enable,jdbcType=BIT}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}